<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */

    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Delete File
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.10.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxDeleteDatablock
    ****
    * @package ajax
    * @author tb@essentialmind.com
    * @version n/a
    * @since 10.05.201
    * @copyright essentialmind.com 2005
    ***/
    class ajaxReorderEstateImages extends ajaxAction{

        public function process(){
            
            /* 
             * in order to handle the output of Sortable.serialize we have to parse the output of this function
             * @see script.aculo.us Sortable
             * @see http://zenofshen.com/posts/ajax-sortable-lists-tutorial
             */
                
            parse_str($_REQUEST['order_pos']);
            
            var_dump($estatepictures);
            if(is_array($estatepictures)) {

                //update database
                $pos=1;
                foreach($estatepictures as $item) {
                    $this->db->Execute("UPDATE estate_pictures SET order_pos = " . (int)$pos . " WHERE id = ".(int)$item);
                    $pos++;
                }
                    
                
                $this->r->status = true;
            } else {
                $this->r->status = false;
            }

        }
    }
?>